package cn.edu.ctbu.dp01.dao;

import cn.edu.ctbu.dp01.entity.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface StudentRepository extends JpaRepository<Student,Integer> {
    List<Student> findByNameLike(String name);


    List<Student> findByNameAndAge(String name,int age);

    @Modifying
    @Transactional
    @Query(value="update tb_student set id =:id where name =:name",nativeQuery = true)
    int updateStudent(Integer id,String name);

    public List<Student> findBySno(String sno);
}
